home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / batch / tsbat36.zip / UNPACK.BAT < prev    next >
DOS Batch File  |  1992-02-04  |  5KB  |  137 lines

  1. echo off
  2. echo.
  3. echo ┌───────────────────────────────────────────────────┐
  4. echo │ Unpack, test, or view any kind of archive         │
  5. echo │ By Prof. Timo Salmi, ts@chyde.uwasa.fi, 4-Feb-92  │
  6. echo └───────────────────────────────────────────────────┘
  7.  
  8. rem When one writes many utilities, getting new ideas is the more critical
  9. rem part than the actual programming. Sometimes it is difficult to pinpoint
  10. rem where exactly the ideas come from, but this one clearly owes an
  11. rem acknowledgement to the posting by John LaRue (7 Mar 90) in the InterNet
  12. rem news in comp.binaries.ibm.pc.d for the general idea. All the details,
  13. rem the idea of using switches and using the file list, and the actual
  14. rem programming are entirely my own, though.
  15.  
  16. if "%1"=="" goto _help
  17.  
  18. rem Get the arhive name, the parameters, and the filenames
  19. set _choice=_usage
  20. set _archive=%1
  21. set _files=
  22. :_loop
  23. shift
  24. if "%1"=="" goto %_choice%
  25. if "%1"=="/e" set _choice=_extract
  26. if "%1"=="/e" goto _loop
  27. if "%1"=="/E" set _choice=_extract
  28. if "%1"=="/E" goto _loop
  29. if "%1"=="/t" set _choice=_test
  30. if "%1"=="/t" goto _loop
  31. if "%1"=="/T" set _choice=_test
  32. if "%1"=="/T" goto _loop
  33. if "%1"=="/v" set _choice=_view
  34. if "%1"=="/v" goto _loop
  35. if "%1"=="/V" set _choice=_view
  36. if "%1"=="/V" goto _loop
  37. set _files=%_files% %1
  38. goto _loop
  39.  
  40. :_extract
  41. set _return=_extr1
  42. goto _subru
  43. :_extr1
  44. if "%_type%"=="arc" pkunpak -e %_archive%.arc %_files%
  45. if "%_type%"=="zip" pkunzip %_archive%.zip %_files%
  46. if "%_type%"=="lzh" lharc e %_archive%.lzh %_files%
  47. if "%_type%"=="zoo" zoo e %_archive%.zoo %_files%
  48. if "%_type%"=="pak" pak e %_archive%.pak %_files%
  49. if "%_type%"=="sdn" pak e %_archive%.sdn %_files%
  50. if "%_type%"=="arj" arj e %_archive%.arj %_files%
  51. goto _out
  52.  
  53. :_test
  54. set _return=_test1
  55. goto _subru
  56. :_test1
  57. if "%_type%"=="arc" pkunpak -t %_archive%.arc %_files%
  58. if "%_type%"=="zip" pkunzip -t %_archive%.zip %_files%
  59. if "%_type%"=="lzh" lharc t %_archive%.lzh %_files%
  60. if "%_type%"=="zoo" zoo -test %_archive%.zoo %_files%
  61. if "%_type%"=="pak" pak t %_archive%.pak %_files%
  62. if "%_type%"=="sdn" pak t %_archive%.sdn %_files%
  63. if "%_type%"=="arj" arj t %_archive%.arj %_files%
  64. goto _out
  65.  
  66. :_view
  67. set _return=_view1
  68. goto _subru
  69. :_view1
  70. if "%_type%"=="arc" pkunpak -v %_archive%.arc %_files%
  71. if "%_type%"=="zip" pkunzip -v %_archive%.zip %_files%
  72. if "%_type%"=="lzh" lharc v %_archive%.lzh %_files%
  73. if "%_type%"=="zoo" zoo v %_archive%.zoo %_files%
  74. if "%_type%"=="pak" pak v %_archive%.pak %_files%
  75. if "%_type%"=="sdn" pak v %_archive%.sdn %_files%
  76. if "%_type%"=="arj" arj v %_archive%.arj %_files%
  77. goto _out
  78.  
  79. rem Subroutine for identifying the archive type and parsing the archive name
  80. rem If the same archive has been packed with several methods .arc takes
  81. rem precedence, then .zip, and so on
  82. :_subru
  83. set _type=
  84. if exist %_archive%.arj set _type=arj
  85. if exist %_archive%.sdn set _type=sdn
  86. if exist %_archive%.pak set _type=pak
  87. if exist %_archive%.zoo set _type=zoo
  88. if exist %_archive%.lzh set _type=lzh
  89. if exist %_archive%.zip set _type=zip
  90. if exist %_archive%.arc set _type=arc
  91. if "%_type%"=="" goto _notfound
  92. rem Check that no wildcards or extension was used
  93. for %%f in (%_archive%.%_type%) do if "%%f"=="%_archive%.%_type%" goto _ok
  94. echo.
  95. echo Wildcards / extensions not allowed in %_archive%
  96. goto _out
  97. :_ok
  98. goto %_return%
  99.  
  100. rem Archive does not exist
  101. :_notfound
  102. echo.
  103. echo File %_archive%.arc[.zip.lzh.zoo.pak.sdn.arj] not found
  104. set _choice=_usage
  105. goto _usage
  106.  
  107. :_help
  108. :_usage
  109. echo.
  110. echo Usage: UNPACK ArchiveName [FileNames] { /e : /t : /v }
  111. echo                                          │    │    └─ view contents
  112. echo                                          │    └─ test integrity
  113. echo                                          └─ extract files
  114. echo  ┌───────────────────────────────────────────┐
  115. echo  │ Archive name: NO WILDCARDS! NO EXTENSION! │
  116. echo  └───────────────────────────────────────────┘
  117. if "%_choice%"=="_usage" goto _out
  118. echo.
  119. echo Examples: UNPACK b:\tsutil30 /v d*.exe
  120. echo.
  121. echo Before you can use this batch, you must make the following programs
  122. echo available at your path (or include the relevant paths in the batch):
  123. echo pkunpak.exe, pkunzip.exe, lcarc.exe, pak.exe, zoo.exe, and arj.exe.
  124. echo.
  125. echo If you get an "Out of environment space" message, increase your
  126. echo environment space by using shell configuration in config.sys:
  127. echo MsDos 3.30 example: shell=c:\bin\command.com /e:1024 /p
  128. goto _out
  129.  
  130. :_out
  131. set _choice=
  132. set _archive=
  133. set _files=
  134. set _type=
  135. set _return=
  136. echo on
  137.